{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Linear regression with ``gluon``\n",
    "\n",
    "Now that we've implemented a whole neural network from scratch, using nothing but ``mx.ndarray`` and ``mxnet.autograd``, let's see how we can make the same model while doing a lot less work. \n",
    "\n",
    "Again, let's import some packages, this time adding ``mxnet.gluon`` to the list of dependencies."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function\n",
    "import mxnet as mx\n",
    "from mxnet import nd, autograd, gluon"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set the context\n",
    "\n",
    "We'll also want to set a context to tell gluon where to do most of the computation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data_ctx = mx.cpu()\n",
    "model_ctx = mx.cpu()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Build the dataset\n",
    "\n",
    "Again we'll look at the problem of linear regression and stick with the same synthetic data. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "num_inputs = 2\n",
    "num_outputs = 1\n",
    "num_examples = 10000\n",
    "\n",
    "def real_fn(X):\n",
    "    return 2 * X[:, 0] - 3.4 * X[:, 1] + 4.2\n",
    "    \n",
    "X = nd.random_normal(shape=(num_examples, num_inputs))\n",
    "noise = 0.01 * nd.random_normal(shape=(num_examples,))\n",
    "y = real_fn(X) + noise"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load the data iterator\n",
    "\n",
    "We'll stick with the ``DataLoader`` for handling our data batching."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "batch_size = 4\n",
    "train_data = gluon.data.DataLoader(gluon.data.ArrayDataset(X, y),\n",
    "                                      batch_size=batch_size, shuffle=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Define the model\n",
    "\n",
    "When we implemented things from scratch, \n",
    "we had to individually allocate parameters \n",
    "and then compose them together as a model. \n",
    "While it's good to know how to do things from scratch, \n",
    "with `gluon`, we can just compose a network from predefined layers. \n",
    "For a linear model, the appropriate layer is called `Dense`. \n",
    "It's called a *dense* layer because every node in the input \n",
    "is connected to every node in the subsequent layer. \n",
    "That description seems excessive \n",
    "because we only have one (non-input) layer here, \n",
    "and that layer only contains one node!\n",
    "But in subsequent chapters we'll typically work \n",
    "with networks that have multiple outputs, \n",
    "so we might as well start thinking in terms of layers of nodes. \n",
    "Because a linear model consists of just a single `Dense` layer, we can instantiate it with one line.\n",
    "\n",
    "As in [the previous notebook](linear-regression-scratch.ipynb), \n",
    "we have an input dimension of 2 and an output dimension of 1. \n",
    "the most direct way to instantiate a ``Dense`` layer with these dimensions\n",
    "is to specify the number of inputs and the number of outputs. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "net = gluon.nn.Dense(1, in_units=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That's it! We've already got a neural network. \n",
    "Like our hand-crafted model in the previous notebook, \n",
    "this model has a weight matrix and bias vector."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Parameter dense4_weight (shape=(1, 2), dtype=None)\n",
       "Parameter dense4_bias (shape=(1,), dtype=None)\n"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(net.weight)\n",
    "print(net.bias)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here, `net.weight` and `net.bias` are not actually NDArrays.\n",
    "They are instances of the `Parameter` class.\n",
    "We use `Parameter` instead of directly accessing NDAarrays for several reasons. \n",
    "For example, they provide convenient abstractions for initializing values.\n",
    "Unlike NDArrays, Parameters can be associated with multiple contexts simultaneously.\n",
    "This will come in handy in future chapters when we start thinking about distributed learning across multiple GPUs.\n",
    "\n",
    "In `gluon`, all neural networks are made out of Blocks (`gluon.Block`).\n",
    "Blocks are just units that take inputs and generate outputs.\n",
    "Blocks also contain parameters that we can update. \n",
    "Here, our network consists of only one layer, \n",
    "so it's convenient to access our parameters directly. \n",
    "When our networks consist of 10s of layers, this won't be so fun.\n",
    "No matter how complex our network, \n",
    "we can grab all its parameters by calling `collect_params()` as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dense4_ (\n",
       "  Parameter dense4_weight (shape=(1, 2), dtype=None)\n",
       "  Parameter dense4_bias (shape=(1,), dtype=None)\n",
       ")"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "net.collect_params()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The returned object is a `gluon.parameter.ParameterDict`. \n",
    "This is a convenient abstraction for retrieving and manipulating groups of Parameter objects.\n",
    "Most often, we'll want to retrieve all of the parameters in a neural network:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "mxnet.gluon.parameter.ParameterDict"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(net.collect_params())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Initialize parameters\n",
    "Once we initialize our Parameters, we can access their underlying data and context(s),\n",
    "and we can also feed data through the neural network to generate output.\n",
    "However, we can't get going just yet. \n",
    "If we try invoking your model by calling ``net(nd.array([[0,1]]))``, \n",
    "we'll confront the following hideous error message:\n",
    "\n",
    "```RuntimeError: Parameter dense1_weight has not been initialized...```\n",
    "\n",
    "That's because we haven't yet told ``gluon`` what the *initial values* for our parameters should be!\n",
    "We initialize parameters by calling the `.initialize()` method of a ParameterDict. \n",
    "We'll need to pass in two arguments. \n",
    "\n",
    "* An initializer, many of which live in the `mx.init` module. \n",
    "* A context where the parameters should live. In this case we'll pass in the `model_ctx`. Most often this will either be a GPU or a list of GPUs. \n",
    "\n",
    "*MXNet* provides a variety of common initializers in ``mxnet.init``.\n",
    "To keep things consistent with the model we built by hand, \n",
    "we'll initialize each parameter by sampling from a standard normal distribution, \n",
    "using `mx.init.Normal(sigma=1.)`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "net.collect_params().initialize(mx.init.Normal(sigma=1.), ctx=model_ctx)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Deferred Initialization\n",
    "\n",
    "When we call ``initialize``, ``gluon`` associates each parameter with an initializer.\n",
    "However, the *actual initialization* is deferred until we make a first forward pass. \n",
    "In other words, the parameters are only initialized when they're needed. \n",
    "If we try to call `net.weight.data()` we'll get the following error:\n",
    "\n",
    "``DeferredInitializationError: Parameter dense2_weight has not been initialized yet because initialization was deferred. Actual initialization happens during the first forward pass. Please pass one batch of data through the network before accessing Parameters.``\n",
    "\n",
    "Passing data through a `gluon` model is easy. \n",
    "We just sample a batch of the appropriate shape and call `net` \n",
    "just as if it were a function. \n",
    "This will invoke `net`'s `forward()` method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\n",
       "[[-1.33219385]]\n",
       "<NDArray 1x1 @cpu(0)>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "example_data = nd.array([[4,7]])\n",
    "net(example_data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now that `net` is initialized, we can access each of its parameters. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "[[-0.25217363 -0.04621419]]\n",
      "<NDArray 1x2 @cpu(0)>\n",
      "\n",
      "[ 0.]\n",
      "<NDArray 1 @cpu(0)>\n"
     ]
    }
   ],
   "source": [
    "print(net.weight.data())\n",
    "print(net.bias.data())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Shape inference\n",
    "\n",
    "Recall that previously, we instantiated our network with `gluon.nn.Dense(1, in_units=2)`. \n",
    "One slick feature that we can take advantage of in ``gluon`` is shape inference on parameters. \n",
    "Because our parameters never come into action until we pass data through the network,\n",
    "we don't actually have to declare the input dimension (`in_units`). \n",
    "Let's try this again, but letting `gluon` do more of the work:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "net = gluon.nn.Dense(1)\n",
    "net.collect_params().initialize(mx.init.Normal(sigma=1.), ctx=model_ctx)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We'll elaborate on this and more of ``gluon``'s internal workings in subsequent chapters."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Define loss\n",
    "\n",
    "Instead of writing our own loss function we're just going to access squared error by instantiating ``gluon.loss.L2Loss``. Just like layers, and whole networks, a loss in gluon is just a `Block`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "square_loss = gluon.loss.L2Loss()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Optimizer\n",
    "Instead of writing stochastic gradient descent from scratch every time, we can instantiate a ``gluon.Trainer``, passing it a dictionary of parameters. Note that the ``SGD`` optimizer in ``gluon`` also has a few bells and whistles that you can turn on at will, including *momentum* and *clipping* (both are switched off by default). These modifications can help to converge faster and we'll discuss them later when we go over a variety of optimization algorithms in detail."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "trainer = gluon.Trainer(net.collect_params(), 'sgd', {'learning_rate': 0.0001})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Execute training loop\n",
    "\n",
    "You might have noticed that it was a bit more concise to express our model in ``gluon``. For example, we didn't have to individually allocate parameters, define our loss function, or implement stochastic gradient descent. The benefits of relying on ``gluon``'s abstractions will grow substantially once we start working with much more complex models. But once we have all the basic pieces in place, the training loop itself is quite similar to what we would do if implementing everything from scratch. \n",
    "\n",
    "To refresh your memory. For some number of ``epochs``, we'll make a complete pass over the dataset (``train_data``), grabbing one mini-batch of inputs and the corresponding ground-truth labels at a time. \n",
    "\n",
    "Then, for each batch, we'll go through the following ritual. So that this process becomes maximally ritualistic, we'll repeat it verbatim:\n",
    "\n",
    "* Generate predictions (``yhat``) and the loss (``loss``) by executing a forward pass through the network.\n",
    "* Calculate gradients by making a backwards pass through the network via ``loss.backward()``. \n",
    "* Update the model parameters by invoking our SGD optimizer (note that we need not tell ``trainer.step`` about which parameters but rather just the amount of data, since we already performed that in the initialization of ``trainer``).\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0, loss: 3.44980202263\n",
      "Epoch 1, loss: 2.10364257665\n",
      "Epoch 2, loss: 1.28279426137\n",
      "Epoch 3, loss: 0.782256319318\n",
      "Epoch 4, loss: 0.477034088909\n",
      "Epoch 5, loss: 0.290909814427\n",
      "Epoch 6, loss: 0.177411796283\n",
      "Epoch 7, loss: 0.108197494675\n",
      "Epoch 8, loss: 0.0659899789031\n",
      "Epoch 9, loss: 0.040249745576\n"
     ]
    }
   ],
   "source": [
    "epochs = 10\n",
    "loss_sequence = []\n",
    "num_batches = num_examples / batch_size\n",
    "\n",
    "for e in range(epochs):\n",
    "    cumulative_loss = 0\n",
    "    # inner loop\n",
    "    for i, (data, label) in enumerate(train_data):\n",
    "        data = data.as_in_context(model_ctx)\n",
    "        label = label.as_in_context(model_ctx)\n",
    "        with autograd.record():\n",
    "            output = net(data)\n",
    "            loss = square_loss(output, label)\n",
    "        loss.backward()\n",
    "        trainer.step(batch_size)\n",
    "        cumulative_loss += nd.mean(loss).asscalar()\n",
    "    print(\"Epoch %s, loss: %s\" % (e, cumulative_loss / num_examples))\n",
    "    loss_sequence.append(cumulative_loss)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Visualizing the learning curve\n",
    "Now let's check how quickly SGD learns the linear regression model by plotting the learning curve."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.text.Text at 0x7efc87a7f0f0>"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAggAAAF7CAYAAAC3onORAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4lOW9//H3NztJIOwBQlgUEBAEJCBWq7iDVkGrqN2s\ntcXTalf9tWp7ao/V9pzWLnpOa8WlajfBBUVF0apxaQVBQFYRRFnCvhOQhCTf3x/zBAcSZICZeSaT\nz+u65soz97PMd+4LzSfPct/m7oiIiIhEywi7ABEREUk9CggiIiLSgAKCiIiINKCAICIiIg0oIIiI\niEgDCggiIiLSgAKCiIiINKCAICIiIg0oIIiIiEgDCggiIiLSQFbYBYStffv23qNHj7gdb9euXRQU\nFMTteNI49XNyqJ+TR32dHOpneOeddza5e4dDbdfsA0KPHj2YNWtW3I5XXl7OyJEj43Y8aZz6OTnU\nz8mjvk4O9TOY2YpYttMlBhEREWlAAUFEREQaUEAQERGRBhQQREREpIG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9W4CfgCcCKwALnb31QDuXmFmo4FfB/ttA/4O\n3BK1/83A1uCzugaf90jivpKIHIyeYhCRoxb1hMEwd58VbjUiEg+6B0FEREQaUEAQERGRBnSJQURE\nRBrQGQQRERFpQAFBREREGlBAEBERkQYUEERERKQBBQQRERFpQAFBREREGvj/dp/IjX+o6UAAAAAA\nSUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7efc908d94a8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot the convergence of the estimated loss function \n",
    "%matplotlib inline\n",
    "\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "plt.figure(num=None,figsize=(8, 6))\n",
    "plt.plot(loss_sequence)\n",
    "\n",
    "# Adding some bells and whistles to the plot\n",
    "plt.grid(True, which=\"both\")\n",
    "plt.xlabel('epoch',fontsize=14)\n",
    "plt.ylabel('average loss',fontsize=14)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As we can see, the loss function converges quickly to the optimal solution."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Getting the learned model parameters\n",
    "\n",
    "As an additional sanity check, since we generated the data from a Gaussian linear regression model, we want to make sure that the learner managed to recover the model parameters, which were set to weight $2,-3.4$ with an offset of $4.2$.\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The type of \"params\" is a  <class 'mxnet.gluon.parameter.ParameterDict'>\n",
      "dense5_weight \n",
      "[[ 1.7913872  -3.10427046]]\n",
      "<NDArray 1x2 @cpu(0)>\n",
      "dense5_bias \n",
      "[ 3.85259581]\n",
      "<NDArray 1 @cpu(0)>\n"
     ]
    }
   ],
   "source": [
    "params = net.collect_params() # this returns a ParameterDict\n",
    "\n",
    "print('The type of \"params\" is a ',type(params))\n",
    "\n",
    "# A ParameterDict is a dictionary of Parameter class objects\n",
    "# therefore, here is how we can read off the parameters from it.\n",
    "\n",
    "for param in params.values():\n",
    "    print(param.name,param.data())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Conclusion \n",
    "\n",
    "As you can see, even for a simple example like linear regression, ``gluon`` can help you to write quick and clean code. Next, we'll repeat this exercise for multi-layer perceptrons, extending these lessons to deep neural networks and (comparatively) real datasets. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Next\n",
    "[Binary classification with logistic regression](../chapter02_supervised-learning/logistic-regression-gluon.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "For whinges or inquiries, [open an issue on  GitHub.](https://github.com/zackchase/mxnet-the-straight-dope)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
